package org.jeecg.modules.villageCadreAssist.util;

import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.system.vo.ExtraData;

public class CommonUtil {

    public static void nameOrLetter(ExtraData data){
        String firstLetter = data.getString("firstLetter");
        if(StringUtils.isNotEmpty(firstLetter)) {
            if (firstLetter.matches("^[a-zA-Z]+$")) {
                data.put("firstLetter",firstLetter.toLowerCase());
            } else {
                data.remove("firstLetter");
                data.put("residentName",firstLetter);
            }
        }
    }
    public static String checkOrgCode(ExtraData data){
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String orgCode = user.getOrgCode();
        String paramCode = data.getString("orgCode");
        if(paramCode!=null && paramCode.startsWith(orgCode)){
            orgCode = paramCode;
        }
        data.put("orgCode",orgCode);
        return orgCode;
    }

//    public static void beforePage(ExtraData data){
//        nameOrLetter(data);
//        checkOrgCode(data);
//    }

}
